import { reqGetTradeListData } from '@/api';

const state = {
    tradeInfo:{}
}

const actions = {
    // 获取trade页面数据
    async getTradeListData({commit}){
        const result = await reqGetTradeListData()
        if (result.code === 200){
            commit('SAVE_TRADE_INFO_DATA',result.data)
        }else {
            console.log(result.message);
        }
    }
}

const mutations = {
    SAVE_TRADE_INFO_DATA(state,tradeInfo) {
        state.tradeInfo = tradeInfo
    }
}

const getters = {
    // 1 商品详情列表
    detailArrayList(state) {
        return state.tradeInfo.detailArrayList
    },
    // 2 原始商品总金额 不加优惠劵邮费
    originalTotalAmount(state) {
        return state.tradeInfo.originalTotalAmount
    },
    // 3 实现金额
    totalAmount(state) {
        return state.tradeInfo.totalAmount
    },
    // 4 订单编号
    tradeNo(state) {
        return state.tradeInfo.tradeNo
    },
    // 5 商品数量
    totalNum(state) {
        return state.tradeInfo.totalNum
    }
}

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
  }